﻿@using Magicodes.WeChat.SDK
@using Magicodes.WeiChat.Infrastructure.Identity
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
    using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
    {
        var weiXinAccount = "未配置公众号";
        var tenantName = "未找到租户名称";
        var config = WeChatConfigManager.Current.GetConfig();
        var tenant = User.Identity.GetTenantInfo();
        if (config!=null)
        {
            weiXinAccount = config.WeiXinAccount;
        }
        if (tenant!=null)
        {
            tenantName = tenant.Name;
        }
        @Html.AntiForgeryToken()

        <ul class="nav navbar-top-links navbar-right" id="topLoginPartial">
            <li>
                【@(tenantName)（微信号：@weiXinAccount）】&nbsp;&nbsp;
            </li>
            <li>
                欢迎 @User.Identity.GetUserName() ！
            </li>
            @if (User.IsInRole("Admin"))
            {
                <li>@Html.Action("GetSystemAdminHomeHtml", "Unity")</li>
            }
            <!-- ko component:{name: "notify"} -->
            <!-- /ko -->
            <li>
                <a href="javascript:document.getElementById('logoutForm').submit()">
                    <i class="fa fa-sign-out"></i> 注销
                </a>
            </li>
        </ul>
    }
}
else
{
    <ul class="nav navbar-top-links navbar-right">
        <li>@Html.ActionLink("登陆", "Login", "Account", null, new { id = "loginLink" })</li>
    </ul>
}